package com.ylbh.modules.cancellation.controller;

import com.ylbh.common.annotation.SysLog;
import com.ylbh.common.pojo.cancellation.dto.CancellationDTO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.cancellation.service.ShoppingUserCancellationService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ylbh.common.utils.PageUtils;



/**
 * 用户注销信息表
 *
 * @author czx
 * @date 2019-11-16 18:33:59
 */
@RestController
@RequestMapping("cancellation")
public class ShoppingUserCancellationController {

    @Autowired
    private ShoppingUserCancellationService shoppingUserCancellationService;

    @ApiOperation("用户注销列表")
    @GetMapping("/queryCancellationList")
//    @RequiresPermissions("cancellation:list")
    public CommonResult queryCancellationList(CancellationDTO dto){
        PageUtils page = shoppingUserCancellationService.queryCancellationList(dto);
        return Ref.ok(page);
    }

    @SysLog("注销用户审核")
    @ApiOperation("注销用户审核")
    @PostMapping("/toExamine")
//    @RequiresPermissions("cancellation:toExamine")
    public CommonResult toExamine(@RequestBody CancellationDTO dto){
		String msg = shoppingUserCancellationService.cancellationToExamine(dto);
		if ("失败".equals(msg))
		    return Ref.error("该用户还有未完成的订单！");
		else
            return Ref.ok();
    }

}
